const Koa = require('koa');
const cors = require('koa2-cors');
const Router = require('koa-router');
const router = new Router();
router.get('/', (ctx, next) => {
    ctx.body = JSON.stringify({
        msg: 'hello'
    });
    next();
});

function sleep(){
    return new Promise(re=>{
        setTimeout(re,1000);
    })
}
router.post('/file', async (ctx, next) => {
    ctx.body = JSON.stringify({
        msg: 'hello'
    });
    await sleep();
    next();
});
const app = new Koa();
app.use(cors());
app.use(router.routes()).use(router.allowedMethods());
app.listen(8090);
